package com.park.platform.service.impl;

import com.park.common.bean.ActivityInputView;
import com.park.common.bean.ArticleInputView;
import com.park.common.bean.CommentInputView;
import com.park.common.bean.PageBean;
import com.park.common.constant.IDBConstant;
import com.park.platform.dao.IBaseDao;
import com.park.platform.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by Administrator on 2017-05-01.
 */
@Service
public class HomeServiceImpl extends BaseService implements IHomeService {

    @Autowired
    private IBaseDao baseDao;

    @Autowired
    private IArticleService articleService;

    @Autowired
    private IActivityService activityService;

    @Autowired
    private ICommentService commentService;

    @Autowired
    private IBannerService bannerService;

    @Override
    public Map<String, Object> getIndex(){
        Map<String, Object> resultMap = new HashMap<>();

        ArticleInputView articleInputView = new ArticleInputView();
        articleInputView.setPageSize(2D);
        PageBean articlePageBean = articleService.getArticles(articleInputView);
        resultMap.put("articles", articlePageBean.getList());

        ActivityInputView activityInputView = new ActivityInputView();
        activityInputView.setPageSize(4D);
        PageBean activityPageBean = activityService.getActivitys(activityInputView);
        resultMap.put("activitys", activityPageBean.getList());

        CommentInputView commentInputView = new CommentInputView();
        commentInputView.setPageSize(4D);
        PageBean commentPageBean = commentService.getComments(commentInputView);
        resultMap.put("comments", commentPageBean.getList());

        articleInputView.setServiceType(IDBConstant.LOGIC_STATUS_NO);
        PageBean newsPageBean = articleService.getArticles(articleInputView);
        resultMap.put("newss", newsPageBean.getList());

        resultMap.put("personalitys", bannerService.getPersonalitys());
        return resultMap;
    }

}
